#1.Prelims ----
library(ggplot2)
library(ggmap)
library(usmap)
library(mapdata)
library(ggthemes)
library(dplyr)
library(RColorBrewer)
library(viridis)
library(maps)
library(cowplot) # for plot_grid() function - good to arrange multiple plots into a grid
library(grid)
library(gridGraphics)
library(patchwork)
library(gridExtra)
library(colorspace)


library(ggpubr)
require(maps)
require(viridis)

theme_set(
  theme_void()
)

theme_set(theme_classic())

#2.Paths ----


BASEPATH="C://Users//wb520443//Dropbox//Research Projects//Global pollution//2_analysis//Replication"

#3.Data ----
#Pollution data
bin_rwi<-read.csv(paste0(BASEPATH,"/figdat/binned_rwi.csv"), header = TRUE)



#4. Bar chart ----
pm_wealth_bins<-ggplot(bin_rwi, aes(x = bin, y=wealth,fill = urca_mean)) +
    geom_bar(stat='identity') +
   scale_fill_continuous_sequential(palette = 'Heat', 
                                   na.value = "grey90",
                                   guide="none")+
  theme(text = element_text(size = 15))+ 
  theme(legend.background=element_blank())+
  theme(axis.line.x = element_blank(),
        axis.line.y = element_blank())+
  ylab(element_blank())+
  xlab("5 ug/m3 PM2.5 bins")+
  scale_y_continuous(breaks=c(0,0.9),labels = paste0(c("Low","High")))+
  scale_x_continuous(breaks=c(1,5,10,15,20),labels = paste0(c("0-5", "25-30","50-55","75-80","95+")))





ggsave(filename = paste0(BASEPATH,"//figures//pm_wealth_bins_tall.pdf"), 
       plot = pm_wealth_bins,        width =3,
       height = 5,
       units = c("in"),
       dpi = 300)
